﻿#pragma strict


private var room : GameObject;
private var childs : int;


function floorComplete(floor : int){
	childs = transform.childCount;
}

function roomPosition(ID : int){
	//Debug.Log("roomPosition: "+ ID);
	yield transform.childCount;
	
	if(gameObject.name == "floor0" && ID == 0){
		room = GameObject.Find(gameObject.name+"/room"+ID);
		room.SendMessage("setType", "start");
		Debug.Log("start");
		
	} else if(gameObject.name == "floor0" && ID == 1){
		room = GameObject.Find(gameObject.name+"/room"+ID);
		room.SendMessage("setType", "middle");
		Debug.Log("middle");
		
		} else if(ID == 1){
			room = GameObject.Find(gameObject.name+"/room"+ID);
			room.SendMessage("setType", "cornerL");
			Debug.Log("cornerL");
		
			} else if(ID == childs){
				room = GameObject.Find(gameObject.name+"/room"+ID);
				room.SendMessage("setType", "cornerR");
				Debug.Log("cornerR");
			
				} else if(ID > 1){
					room = GameObject.Find(gameObject.name+"/room"+ID);
					room.SendMessage("setType", "middle");
					Debug.Log("middle");
					}
}


